<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="keywords" content="vue学习之绑定与指令">
    <style>
        .red {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <div>
            <h1>水果</h1>
            <ul>
                <li v-for="fruit in fruits">{{fruit}}</li>
            </ul>
            <h1>作者</h1>
            <span> 姓名：{{author.name}}</span>
            <span>年龄：{{author.age}}</span>
            <span>学校：{{author.school}}</span>
            <button v-on:click="add">年龄加1</button>
        </div>
        <hr/>
        <div>
            <p v-html="rawHtml"></p>
            <a v-bind:href="url">百度一下</a>
            <br/>
            <button @click="seen=!seen">切换</button>
            <p v-if="seen">现在可以看见了</p>
        </div>
    </div>
    <script src="vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                fruits: ["apple", "pear", "grape"],
                author: {
                    name: "李向维",
                    age: 22,
                    school: "中南大学"
                },
                url: "http://www.baidu.com",
                rawHtml: "<span>解析为html片段</span>",
                seen: true
            },
            methods: {
                add: function () {
                    this.author.age += 1;
                }

            }
        });
    </script>
</body>

</html>